home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / gnu / gpp-1_42.lha / g++-1.42.0 / dbxout.c < prev    next >
C/C++ Source or Header  |  1991-10-19  |  45KB  |  1,537 lines

  1. /* Output dbx-format symbol table information from GNU compiler.
  2.    Copyright (C) 1987, 1988 Free Software Foundation, Inc.
  3.  
  4. This file is part of GNU CC.
  5.  
  6. GNU CC is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 1, or (at your option)
  9. any later version.
  10.  
  11. GNU CC is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GNU CC; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20.  
  21. /* Output dbx-format symbol table data.
  22.    This consists of many symbol table entries, each of them
  23.    a .stabs assembler pseudo-op with four operands:
  24.    a "name" which is really a description of one symbol and its type,
  25.    a "code", which is a symbol defined in stab.h whose name starts with N_,
  26.    an unused operand always 0,
  27.    and a "value" which is an address or an offset.
  28.    The name is enclosed in doublequote characters.
  29.  
  30.    Each function, variable, typedef, and structure tag
  31.    has a symbol table entry to define it.
  32.    The beginning and end of each level of name scoping within
  33.    a function are also marked by special symbol table entries.
  34.  
  35.    The "name" consists of the symbol name, a colon, a kind-of-symbol letter,
  36.    and a data type number.  The data type number may be followed by
  37.    "=" and a type definition; normally this will happen the first time
  38.    the type number is mentioned.  The type definition may refer to
  39.    other types by number, and those type numbers may be followed
  40.    by "=" and nested definitions.
  41.  
  42.    This can make the "name" quite long.
  43.    When a name is more than 80 characters, we split the .stabs pseudo-op
  44.    into two .stabs pseudo-ops, both sharing the same "code" and "value".
  45.    The first one is marked as continued with a double-backslash at the
  46.    end of its "name".
  47.  
  48.    The kind-of-symbol letter distinguished function names from global
  49.    variables from file-scope variables from parameters from auto
  50.    variables in memory from typedef names from register variables.
  51.    See `dbxout_symbol'.
  52.  
  53.    The "code" is mostly redundant with the kind-of-symbol letter
  54.    that goes in the "name", but not entirely: for symbols located
  55.    in static storage, the "code" says which segment the address is in,
  56.    which controls how it is relocated.
  57.  
  58.    The "value" for a symbol in static storage
  59.    is the core address of the symbol (actually, the assembler
  60.    label for the symbol).  For a symbol located in a stack slot
  61.    it is the stack offset; for one in a register, the register number.
  62.    For a typedef symbol, it is zero.
  63.  
  64.    If DEBUG_SYMS_TEXT is defined, all debugging symbols must be
  65.    output while in the text section.
  66.  
  67.    For more on data type definitions, see `dbxout_type'.  */
  68.  
  69. #include "config.h"
  70. #include "tree.h"
  71. #include "cplus-tree.h"
  72. #include "rtl.h"
  73. #include "flags.h"
  74. #include <stdio.h>
  75.  
  76. /* Typical USG systems don't have stab.h, and they also have
  77.    no use for DBX-format debugging info.  */
  78.  
  79. #ifdef DBX_DEBUGGING_INFO
  80.  
  81. #ifdef DEBUG_SYMS_TEXT
  82. #define FORCE_TEXT text_section ();
  83. #else
  84. #define FORCE_TEXT
  85. #endif
  86.  
  87. #ifdef USG
  88. #include "stab.h"  /* If doing DBX on sysV, use our own stab.h.  */
  89. #else
  90. #include <stab.h>  /* On BSD, use the system's stab.h.  */
  91. #endif /* not USG */
  92.  
  93. /* Stream for writing to assembler file.  */
  94.  
  95. static FILE *asmfile;
  96.  
  97. enum typestatus {TYPE_UNSEEN, TYPE_XREF, TYPE_DEFINED};
  98.  
  99. /* Vector recording the status of describing C data types.
  100.    When we first notice a data type (a tree node),
  101.    we assign it a number using next_type_number.
  102.    That is its index in this vector.
  103.    The vector element says whether we have yet output
  104.    the definition of the type.  TYPE_XREF says we have
  105.    output it as a cross-reference only.  */
  106.  
  107. enum typestatus *typevec;
  108.  
  109. /* Number of elements of space allocated in `typevec'.  */
  110.  
  111. static int typevec_len;
  112.  
  113. /* In dbx output, each type gets a unique number.
  114.    This is the number for the next type output.
  115.    The number, once assigned, is in the TYPE_SYMTAB_ADDRESS field.  */
  116.  
  117. static int next_type_number;
  118.  
  119. /* In dbx output, we must assign symbol-blocks id numbers
  120.    in the order in which their beginnings are encountered.
  121.    We output debugging info that refers to the beginning and
  122.    end of the ranges of code in each block
  123.    with assembler labels LBBn and LBEn, where n is the block number.
  124.    The labels are generated in final, which assigns numbers to the
  125.    blocks in the same way.  */
  126.  
  127. static int next_block_number;
  128.  
  129. /* These variables are for dbxout_symbol to communicate to
  130.    dbxout_finish_symbol.
  131.    current_sym_code is the symbol-type-code, a symbol N_... define in stab.h.
  132.    current_sym_value and current_sym_addr are two ways to address the
  133.    value to store in the symtab entry.
  134.    current_sym_addr if nonzero represents the value as an rtx.
  135.    If that is zero, current_sym_value is used.  This is used
  136.    when the value is an offset (such as for auto variables,
  137.    register variables and parms).  */
  138.  
  139. static int current_sym_code;
  140. static int current_sym_value;
  141. static rtx current_sym_addr;
  142.  
  143. /* Number of chars of symbol-description generated so far for the
  144.    current symbol.  Used by CHARS and CONTIN.  */
  145.  
  146. static int current_sym_nchars;
  147.  
  148. /* Report having output N chars of the current symbol-description.  */
  149.  
  150. #define CHARS(N) (current_sym_nchars += (N))
  151.  
  152. /* Break the current symbol-description, generating a continuation,
  153.    if it has become long.  */
  154.  
  155. #ifndef DBX_CONTIN_LENGTH
  156. #define DBX_CONTIN_LENGTH 80
  157. #endif
  158.  
  159. #if DBX_CONTIN_LENGTH > 0
  160. #define CONTIN  \
  161.   do {if (current_sym_nchars > DBX_CONTIN_LENGTH) dbxout_continue ();} while (0)
  162. #else
  163. #define CONTIN
  164. #endif
  165.  
  166. void dbxout_types ();
  167. void dbxout_tags ();
  168. void dbxout_args ();
  169. void dbxout_symbol ();
  170. static void dbxout_type_name ();
  171. static void dbxout_type ();
  172. static void dbxout_finish_symbol ();
  173. static void dbxout_continue ();
  174.  
  175. /* At the beginning of compilation, start writing the symbol table.
  176.    Initialize `typevec' and output the standard data types of C.  */
  177.  
  178. void
  179. dbxout_init (asm_file, input_file_name)
  180.      FILE *asm_file;
  181.      char *input_file_name;
  182. {
  183.   asmfile = asm_file;
  184.  
  185.   typevec_len = 100;
  186.   typevec = (enum typestatus *) xmalloc (typevec_len * sizeof typevec[0]);
  187.   bzero (typevec, typevec_len * sizeof typevec[0]);
  188.  
  189.   /* Used to put `Ltext:' before the reference, but that loses on sun 4.  */
  190.   fprintf (asmfile,
  191.        "\t.stabs \"%s\",%d,0,0,Ltext\nLtext:\n",
  192.        input_file_name, N_SO);
  193.  
  194.   next_type_number = 1;
  195.   next_block_number = 2;
  196.  
  197.   /* Make sure that types `int' and `char' have numbers 1 and 2.
  198.      Definitions of other integer types will refer to those numbers.  */
  199.  
  200.   dbxout_symbol (TYPE_NAME (integer_type_node), 0);
  201.   dbxout_symbol (TYPE_NAME (char_type_node), 0);
  202.  
  203.   /* Get all permanent types not yet gotten, and output them.  */
  204.  
  205.   dbxout_types (get_permanent_types ());
  206. }
  207.  
  208. /* Change by Bryan Boreham, Kewill, Sun Aug 13 15:31:25 1989.
  209.    Added to support unexecing of compiler.    */
  210.  
  211. void
  212. re_init_dbxout_for_unexec (asm_file, input_file_name)
  213.      FILE *asm_file;
  214.      char *input_file_name;
  215. {
  216.   asmfile = asm_file;
  217. }
  218.  
  219. /* Continue a symbol-description that gets too big.
  220.    End one symbol table entry with a double-backslash
  221.    and start a new one, eventually producing something like
  222.    .stabs "start......\\",code,0,value
  223.    .stabs "...rest",code,0,value   */
  224.  
  225. static void
  226. dbxout_continue ()
  227. {
  228. #ifdef DBX_CONTIN_CHAR
  229.   fprintf (asmfile, "%c", DBX_CONTIN_CHAR);
  230. #else
  231.   fprintf (asmfile, "\\\\");
  232. #endif
  233.   dbxout_finish_symbol ();
  234.   fprintf (asmfile, ".stabs \"");
  235.   current_sym_nchars = 0;
  236. }
  237.  
  238. /* Output a reference to a type.  If the type has not yet been
  239.    described in the dbx output, output its definition now.
  240.    For a type already defined, just refer to its definition
  241.    using the type number.
  242.  
  243.    If FULL is nonzero, and the type has been described only with
  244.    a forward-reference, output the definition now.
  245.    If FULL is zero in this case, just refer to the forward-reference
  246.    using the number previously allocated.  */
  247.  
  248. static void
  249. dbxout_type (type, full)
  250.      tree type;
  251.      int full;
  252. {
  253.   register tree fields, tem, method_vec;
  254.   tree *methods, *end;
  255.   char *vfield_name = 0;
  256.   tree virtual_basetype = 0;
  257.  
  258.   /* If there was an input error and we don't really have a type,
  259.      avoid crashing and write something that is at least valid
  260.      by assuming `int'.  */
  261.   if (type == error_mark_node)
  262.     type = integer_type_node;
  263.   else /* if (TYPE_SIZE (type) == 0) */
  264.     type = TYPE_MAIN_VARIANT (type);
  265.  
  266.   if (TYPE_SYMTAB_ADDRESS (type) == 0)
  267.     {
  268.       /* Type has no dbx number assigned.  Assign next available number.  */
  269.       TYPE_SYMTAB_ADDRESS (type) = next_type_number++;
  270.  
  271.       /* Make sure type vector is long enough to record about this type.  */
  272.  
  273.       if (next_type_number == typevec_len)
  274.     {
  275.       typevec = (enum typestatus *) xrealloc (typevec, typevec_len * 2 * sizeof typevec[0]);
  276.       bzero (typevec + typevec_len, typevec_len * sizeof typevec[0]);
  277.       typevec_len *= 2;
  278.     }
  279.     }
  280.  
  281.   /* Output the number of this type, to refer to it.  */
  282.   fprintf (asmfile, "%d", TYPE_SYMTAB_ADDRESS (type));
  283.   CHARS (3);
  284.  
  285.   /* If this type's definition has been output or is now being output,
  286.      that is all.  */
  287.  
  288.   switch (typevec[TYPE_SYMTAB_ADDRESS (type)])
  289.     {
  290.     case TYPE_UNSEEN:
  291.       break;
  292.     case TYPE_XREF:
  293.       if (! full)
  294.     return;
  295.       break;
  296.     case TYPE_DEFINED:
  297.       return;
  298.     }
  299.  
  300. #ifdef DBX_NO_XREFS
  301.   /* For systems where dbx output does not allow the `=xsNAME:' syntax,
  302.      leave the type-number completely undefined rather than output
  303.      a cross-reference.  */
  304.   if (TREE_CODE (type) == RECORD_TYPE || TREE_CODE (type) == UNION_TYPE
  305.       || TREE_CODE (type) == ENUMERAL_TYPE)
  306.  
  307.     if ((TYPE_NAME (type) != 0 && !full)
  308.     || TYPE_SIZE (type) == 0)
  309.       {
  310.     typevec[TYPE_SYMTAB_ADDRESS (type)] = TYPE_XREF;
  311.     return;
  312.       }
  313. #endif
  314.  
  315.   /* Output a definition now.  */
  316.  
  317.   fprintf (asmfile, "=");
  318.   CHARS (1);
  319.  
  320.   /* Mark it as defined, so that if it is self-referent
  321.      we will not get into an infinite recursion of definitions.  */
  322.  
  323.   typevec[TYPE_SYMTAB_ADDRESS (type)] = TYPE_DEFINED;
  324.  
  325.   switch (TREE_CODE (type))
  326.     {
  327.     case VOID_TYPE:
  328.     case LANG_TYPE:
  329.       /* For a void type, just define it as itself; ie, "5=5".
  330.      This makes us consider it defined
  331.      without saying what it is.  The debugger will make it
  332.      a void type when the reference is seen, and nothing will
  333.      ever override that default.  */
  334.       fprintf (asmfile, "%d", TYPE_SYMTAB_ADDRESS (type));
  335.       CHARS (3);
  336.       break;
  337.  
  338.     case INTEGER_TYPE:
  339.       if (type == char_type_node && ! TREE_UNSIGNED (type))
  340.     /* Output the type `char' as a subrange of itself!
  341.        I don't understand this definition, just copied it
  342.        from the output of pcc.  */
  343.     fprintf (asmfile, "r2;0;127;");
  344.       else
  345.     /* Output other integer types as subranges of `int'.  */
  346.     fprintf (asmfile, "r1;%d;%d;",
  347.          TREE_INT_CST_LOW (TYPE_MIN_VALUE (type)),
  348.          TREE_INT_CST_LOW (TYPE_MAX_VALUE (type)));
  349.       CHARS (25);
  350.       break;
  351.  
  352.     case REAL_TYPE:
  353.       /* This must be magic.  */
  354.       fprintf (asmfile, "r1;%d;0;",
  355.            TREE_INT_CST_LOW (size_in_bytes (type)));
  356.       CHARS (16);
  357.       break;
  358.  
  359.     case ARRAY_TYPE:
  360.       /* Output "a" followed by a range type definition
  361.      for the index type of the array
  362.      followed by a reference to the target-type.
  363.      ar1;0;N;M for an array of type M and size N.  */
  364.       fprintf (asmfile, "ar1;0;%d;",
  365.            (TYPE_DOMAIN (type)
  366.         ? TREE_INT_CST_LOW (TYPE_MAX_VALUE (TYPE_DOMAIN (type)))
  367.             : -1));
  368.       CHARS (17);
  369.       dbxout_type (TREE_TYPE (type), 0);
  370.       break;
  371.  
  372.     case RECORD_TYPE:
  373.     case UNION_TYPE:
  374.       {
  375.     int i, n_baseclasses = CLASSTYPE_N_BASECLASSES (type);
  376.  
  377.     /* Output a structure type.  */
  378.     if ((TYPE_NAME (type) != 0 && !full)
  379.         || TYPE_SIZE (type) == 0)
  380.       {
  381.         /* If the type is just a cross reference, output one
  382.            and mark the type as partially described.
  383.            If it later becomes defined, we will output
  384.            its real definition.
  385.            If the type has a name, don't nest its name within
  386.            another type's definition; instead, output an xref
  387.            and let the definition come when the name is defined.  */
  388.         fprintf (asmfile, (TREE_CODE (type) == RECORD_TYPE) ? "xs" : "xu");
  389.         CHARS (3);
  390.         dbxout_type_name (type);
  391.         fprintf (asmfile, ":");
  392.         typevec[TYPE_SYMTAB_ADDRESS (type)] = TYPE_XREF;
  393.         break;
  394.       }
  395.     tem = size_in_bytes (type);
  396.     fprintf (asmfile, (TREE_CODE (type) == RECORD_TYPE) ? "s%d" : "u%d",
  397.          TREE_INT_CST_LOW (tem));
  398.  
  399.     if (use_gdb_dbx_extensions)
  400.       {
  401.         if (n_baseclasses)
  402.           {
  403.         fprintf (asmfile, "!%d,", n_baseclasses);
  404.         CHARS (8);
  405.           }
  406.       }
  407.     for (i = 1; i <= n_baseclasses; i++)
  408.       {
  409.         tree basetype = CLASSTYPE_BASECLASS (type, i);
  410.         if (use_gdb_dbx_extensions)
  411.           {
  412.         putc (CLASSTYPE_VIA_VIRTUAL (type, 1) ? '1'
  413.               : '0',
  414.               asmfile);
  415.         putc (CLASSTYPE_VIA_PUBLIC (type, 1) ? '2'
  416.               : '0',
  417.               asmfile);
  418.         fprintf (asmfile, "%d,",
  419.              BITS_PER_UNIT * DECL_OFFSET (TYPE_NAME (basetype)));
  420.         CHARS (15);
  421.         dbxout_type (basetype, full);
  422.         putc (';', asmfile);
  423.           }
  424.         else
  425.           {
  426.         /* Print out the base class information with fields
  427.            which have the same names at the types they hold.  */
  428.         tree name = TREE_CODE (TYPE_NAME (basetype)) == TYPE_DECL
  429.           ? DECL_NAME (TYPE_NAME (basetype)) : TYPE_NAME (basetype);
  430.  
  431.         fprintf (asmfile, "%s:", IDENTIFIER_POINTER (name));
  432.         CHARS (2 + IDENTIFIER_LENGTH (name));
  433.         dbxout_type (basetype, full);
  434.         fprintf (asmfile, ",%d,%d;",
  435.              BITS_PER_UNIT * DECL_OFFSET (TYPE_NAME (basetype)),
  436.              TREE_INT_CST_LOW (TYPE_SIZE (basetype)) * DECL_SIZE_UNIT (basetype));
  437.         CHARS (20);
  438.           }
  439.       }
  440.       }
  441.  
  442.       CHARS (11);
  443.  
  444.       for (tem = TYPE_FIELDS (type); tem; tem = TREE_CHAIN (tem))
  445.     /* Output the name, type, position (in bits), size (in bits)
  446.        of each field.  */
  447.     /* Omit here local type decls until we know how to support them.  */
  448.     if (TREE_CODE (tem) == TYPE_DECL)
  449.       continue;
  450.     /* Omit here the nameless fields that are used to skip bits.  */
  451.     else if (DECL_NAME (tem) != 0 && TREE_CODE (tem) != CONST_DECL)
  452.       {
  453.         /* Continue the line if necessary,
  454.            but not before the first field.  */
  455.         if (tem != TYPE_FIELDS (type))
  456.           CONTIN;
  457.         fprintf (asmfile, "%s:", IDENTIFIER_POINTER (DECL_NAME (tem)));
  458.         CHARS (2 + IDENTIFIER_LENGTH (DECL_NAME (tem)));
  459.         if (use_gdb_dbx_extensions)
  460.           {
  461.         putc ('/', asmfile);
  462. #ifdef TREE_PRIVATE
  463.         putc ((TREE_PRIVATE (tem) ? '0'
  464.               : TREE_PROTECTED (tem) ? '1' : '2'),
  465.               asmfile);
  466. #endif
  467.         CHARS (2);
  468.           }
  469.  
  470.         dbxout_type (TREE_TYPE (tem), 0);
  471.         if (TREE_CODE (tem) == VAR_DECL && TREE_STATIC (tem))
  472.           {
  473.         if (use_gdb_dbx_extensions)
  474.           {
  475.             char *name = DECL_ASSEMBLER_NAME (tem);
  476.  
  477.             /* Adding 1 here only works on systems
  478.                which flush an initial underscore from
  479.                the .stabs entry.  This loses for static names
  480.                which have an initial leading '_' on systems which
  481.                don't use leading underscores.  */
  482.             if (name[0] == '_')
  483.               name += 1;
  484.  
  485.             fprintf (asmfile, ":%s;", name);
  486.             CHARS (strlen (name));
  487.           }
  488.         else
  489.           {
  490.             fprintf (asmfile, ",0,0;");
  491.           }
  492.           }
  493. #if 0
  494.         else if (TREE_CODE (tem) == VAR_DECL || TREE_CODE (tem) == CONST_DECL)
  495.           {
  496.         /* GDB 3.2 can't understand these declarations yet.  */
  497.         continue;
  498.           }
  499. #endif
  500.         else
  501.           {
  502.         fprintf (asmfile, ",%d,%d;", DECL_OFFSET (tem),
  503.              TREE_INT_CST_LOW (DECL_SIZE (tem)) * DECL_SIZE_UNIT (tem));
  504.           }
  505.         CHARS (23);
  506.       }
  507.       /* C++: put out the method names and their parameter lists */
  508.       /* We do constructors, destructor, if any, followed by the method names.  */
  509.       method_vec = use_gdb_dbx_extensions ? CLASSTYPE_METHOD_VEC (type) : NULL_TREE;
  510.       methods = 0;
  511.       end = 0;
  512.       if (use_gdb_dbx_extensions
  513.       && TREE_CODE (type) == RECORD_TYPE
  514.       && (TYPE_HAS_DESTRUCTOR (type) | TYPE_HAS_CONSTRUCTOR (type)))
  515.     {
  516.       tree dtor;
  517.  
  518.       end = TREE_VEC_END (method_vec);
  519.       /* Destructors lie in a special place.  */
  520.       if (TYPE_HAS_DESTRUCTOR (type))
  521.         {
  522.           methods = &TREE_VEC_ELT (method_vec, 0);
  523.           dtor = TREE_VEC_ELT (method_vec, 0);
  524.           tem = TREE_CHAIN (dtor);
  525.         }
  526.       else if (TREE_VEC_LENGTH (method_vec) > 1)
  527.         {
  528.           methods = &TREE_VEC_ELT (method_vec, 1);
  529.           dtor = NULL_TREE;
  530.           tem = *methods;
  531.         }
  532.       else
  533.         {
  534.           methods = end;
  535.           tem = 0;
  536.         }
  537.  
  538.       CHARS (2);
  539.  
  540.       if (tem)
  541.         {
  542.           if (TREE_OPERATOR (tem))
  543.         {
  544.           char *name1 = operator_name_string (DECL_NAME (tem));
  545.           fprintf (asmfile, "op$::%s.", name1);
  546.           CHARS (strlen (name1) + 7);
  547.         }
  548.           else
  549.         {
  550.           fprintf (asmfile, "%s::", IDENTIFIER_POINTER (DECL_ORIGINAL_NAME (tem)));
  551.           CHARS (IDENTIFIER_LENGTH (DECL_ORIGINAL_NAME (tem)) + 3);
  552.         }
  553.  
  554.           while (tem)
  555.         {
  556.           /* Output the name of the field (after overloading), as
  557.              well as the name of the field before overloading, along
  558.              with its parameter list.  */
  559.           tree t;
  560.           char c;
  561.  
  562.           CONTIN;
  563.           /* Get to the FUNCTION_DECL */
  564.           t = tem;
  565.           dbxout_type (TREE_TYPE (t), 0); /* METHOD_TYPE */
  566.           if (DECL_VIRTUAL_P (tem))
  567.             c = '*';
  568.           else if (DECL_STATIC_FUNCTION_P (tem))
  569.             c = '?';
  570.           else
  571.             c = '.';
  572.           fprintf (asmfile, ":%s;%c%c",
  573.                IDENTIFIER_POINTER (DECL_NAME (t)),
  574.                TREE_PRIVATE (tem) ? '0' : TREE_PROTECTED (tem) ? '1' : '2', c);
  575.           CHARS (IDENTIFIER_LENGTH (DECL_NAME (t)) + 5);
  576.           if (DECL_VIRTUAL_P (tem))
  577.             {
  578.               fprintf (asmfile, "%d;",
  579.                    TREE_INT_CST_LOW (DECL_VINDEX (tem)));
  580.               CHARS (8);
  581.             }
  582.           if (tem == dtor)
  583.             break;
  584.           tem = TREE_CHAIN (tem);
  585.           if (tem == NULL_TREE)
  586.             tem = dtor;
  587.         }
  588.           putc (';', asmfile);
  589.         }
  590.       if (methods != end)
  591.         methods++;
  592.     }
  593.       else if (method_vec != NULL_TREE)
  594.     {
  595.       methods = &TREE_VEC_ELT (method_vec, 1);
  596.       end = TREE_VEC_END (method_vec);
  597.     }
  598.  
  599.       for (; methods != end; methods++)
  600.     {
  601.       tem = *methods;
  602.  
  603.       if (tem)
  604.         {
  605.           if (TREE_OPERATOR (tem))
  606.         {
  607.           char *name1 = operator_name_string (DECL_NAME (tem));
  608.           fprintf (asmfile, "op$::%s.", name1);
  609.           CHARS (strlen (name1) + 6);
  610.         }
  611.           else
  612.         {
  613.           fprintf (asmfile, "%s::",
  614.                IDENTIFIER_POINTER (DECL_ORIGINAL_NAME (tem)));
  615.           CHARS (IDENTIFIER_LENGTH (DECL_ORIGINAL_NAME (tem)) + 3);
  616.         }
  617.  
  618.           for (; tem; tem = TREE_CHAIN (tem))
  619.         /* Output the name of the field (after overloading), as
  620.            well as the name of the field before overloading, along
  621.            with its parameter list */
  622.         {
  623.           /* @@ */
  624.           tree t;
  625.           char c;
  626.  
  627.           CONTIN;
  628.  
  629.           /* Get to the FUNCTION_DECL */
  630.           t = tem;
  631.           dbxout_type (TREE_TYPE (t), 0); /* METHOD_TYPE */
  632.           if (DECL_VIRTUAL_P (tem))
  633.             c = '*';
  634.           else if (DECL_STATIC_FUNCTION_P (tem))
  635.             c = '?';
  636.           else
  637.             c = '.';
  638.           fprintf (asmfile, ":%s;%c%c",
  639.                IDENTIFIER_POINTER (DECL_NAME (t)),
  640.                TREE_PRIVATE (tem) ? '0' : TREE_PROTECTED (tem) ? '1' : '2', c);
  641.           CHARS (IDENTIFIER_LENGTH (DECL_NAME (t)) + 6);
  642.           if (DECL_VIRTUAL_P (tem))
  643.             {
  644.               fprintf (asmfile, "%d;",
  645.                    TREE_INT_CST_LOW (DECL_VINDEX (tem)));
  646.               CHARS (8);
  647.             }
  648.         }
  649.           putc (';', asmfile);
  650.           CHARS (1);
  651.         }
  652.     }
  653.  
  654.       putc (';', asmfile);
  655.  
  656.       if (use_gdb_dbx_extensions && TREE_CODE (type) == RECORD_TYPE)
  657.     {
  658.       /* Tell GDB+ that it may keep reading.  */
  659.       putc ('~', asmfile);
  660.       if (TYPE_HAS_DESTRUCTOR (type) && TYPE_HAS_CONSTRUCTOR (type))
  661.         putc ('=', asmfile);
  662.       else if (TYPE_HAS_DESTRUCTOR (type))
  663.         putc ('-', asmfile);
  664.       else if (TYPE_HAS_CONSTRUCTOR (type))
  665.         putc ('+', asmfile);
  666.  
  667.       if (CLASSTYPE_VSIZE (type))
  668.         {
  669.           tree t, v = DECL_NAME (CLASSTYPE_VFIELD (type));
  670.           t = type;
  671.           while (CLASSTYPE_N_BASECLASSES (t) && TYPE_VIRTUAL_P (CLASSTYPE_BASECLASS (t, 1)))
  672.         t = CLASSTYPE_BASECLASS (t, 1);
  673.           putc ('%', asmfile);
  674.           dbxout_type (t, 0);
  675.           fprintf (asmfile, ",%s;", IDENTIFIER_POINTER (v));
  676.           CHARS (IDENTIFIER_LENGTH (v) + 6);
  677.         }
  678.       else
  679.         {
  680.           putc (';', asmfile);
  681.           CHARS (3);
  682.         }
  683.     }
  684.       break;
  685.  
  686.     case ENUMERAL_TYPE:
  687.       if ((TYPE_NAME (type) != 0
  688.        && !full
  689.        && ((TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
  690.         && ! ANON_AGGRNAME_P (DECL_NAME (TYPE_NAME (type))))
  691.            || (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE
  692.            && ! ANON_AGGRNAME_P (TYPE_NAME (type)))))
  693.       || TYPE_SIZE (type) == 0)
  694.     {
  695.       fprintf (asmfile, "xe");
  696.       CHARS (3);
  697.       dbxout_type_name (type);
  698.       typevec[TYPE_SYMTAB_ADDRESS (type)] = TYPE_XREF;
  699.       fprintf (asmfile, ":");
  700.       return;
  701.     }
  702.       putc ('e', asmfile);
  703.       CHARS (1);
  704.       for (tem = TYPE_VALUES (type); tem; tem = TREE_CHAIN (tem))
  705.     {
  706.       fprintf (asmfile, "%s:%d,", IDENTIFIER_POINTER (TREE_PURPOSE (tem)),
  707.            TREE_INT_CST_LOW (TREE_VALUE (tem)));
  708.       CHARS (11 + IDENTIFIER_LENGTH (TREE_PURPOSE (tem)));
  709.       if (TREE_CHAIN (tem) != 0)
  710.         CONTIN;
  711.     }
  712.       putc (';', asmfile);
  713.       CHARS (1);
  714.       break;
  715.  
  716.     case POINTER_TYPE:
  717.       putc ('*', asmfile);
  718.       CHARS (1);
  719.       dbxout_type (TREE_TYPE (type), 0);
  720.       break;
  721.  
  722.     case METHOD_TYPE:
  723.       if (use_gdb_dbx_extensions)
  724.     {
  725.       putc ('#', asmfile);
  726.       CHARS (1);
  727.       dbxout_type (TYPE_METHOD_BASETYPE (type), 0);
  728.       putc (',', asmfile);
  729.       CHARS (1);
  730.       dbxout_type (TREE_TYPE (type), 0);
  731.       dbxout_args (TYPE_ARG_TYPES (type));
  732.       putc (';', asmfile);
  733.       CHARS (1);
  734.     }
  735.       else
  736.     {
  737.       /* Should print as an int, because it is really
  738.          just an offset.  */
  739.       dbxout_type (integer_type_node, 0);
  740.     }
  741.       break;
  742.  
  743.     case OFFSET_TYPE:
  744.       if (use_gdb_dbx_extensions)
  745.     {
  746.       putc ('@', asmfile);
  747.       CHARS (1);
  748.       dbxout_type (TYPE_OFFSET_BASETYPE (type), 0);
  749.       putc (',', asmfile);
  750.       CHARS (1);
  751.       dbxout_type (TREE_TYPE (type), 0);
  752.     }
  753.       else
  754.     {
  755.       /* Should print as an int, because it is really
  756.          just an offset.  */
  757.       dbxout_type (integer_type_node, 0);
  758.     }
  759.       break;
  760.  
  761.     case REFERENCE_TYPE:
  762.       putc (use_gdb_dbx_extensions ? '&' : '*', asmfile);
  763.       CHARS (1);
  764.       dbxout_type (TREE_TYPE (type), 0);
  765.       break;
  766.  
  767.     case FUNCTION_TYPE:
  768.       putc ('f', asmfile);
  769.       CHARS (1);
  770.       dbxout_type (TREE_TYPE (type), 0);
  771.       break;
  772.  
  773.     default:
  774.       abort ();
  775.     }
  776. }
  777.  
  778. /* Output the name of type TYPE, with no punctuation.
  779.    Such names can be set up either by typedef declarations
  780.    or by struct, enum and union tags.  */
  781.  
  782. static void
  783. dbxout_type_name (type)
  784.      register tree type;
  785. {
  786.   tree t;
  787.   if (TYPE_NAME (type) == 0)
  788.     abort ();
  789.   if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
  790.     {
  791.       t = TYPE_NAME (type);
  792.     }
  793.   else if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL)
  794.     {
  795.       t = DECL_NAME (TYPE_NAME (type));
  796.     }
  797.   else
  798.     abort ();
  799.  
  800.   fprintf (asmfile, "%s", IDENTIFIER_POINTER (t));
  801.   CHARS (IDENTIFIER_LENGTH (t));
  802. }
  803.  
  804. /* Output a .stabs for the symbol defined by DECL,
  805.    which must be a ..._DECL node in the normal namespace.
  806.    It may be a CONST_DECL, a FUNCTION_DECL, a PARM_DECL or a VAR_DECL.
  807.    LOCAL is nonzero if the scope is less than the entire file.  */
  808.  
  809. void
  810. dbxout_symbol (decl, local)
  811.      tree decl;
  812.      int local;
  813. {
  814.   int letter = 0;
  815.   tree type = TREE_TYPE (decl);
  816.   char *name;
  817.  
  818.   /* If global, first output all types and all
  819.      struct, enum and union tags that have been created
  820.      and not yet output.  */
  821.  
  822.   if (local == 0)
  823.     {
  824.       /* Send out the types first.  */
  825.       dbxout_types (get_permanent_types ());
  826.       dbxout_tags (gettags ());
  827.     }
  828.  
  829.   current_sym_code = 0;
  830.   current_sym_value = 0;
  831.   current_sym_addr = 0;
  832.  
  833.   /* The output will always start with the symbol name,
  834.      so count that always in the length-output-so-far.  */
  835.  
  836.   if (DECL_NAME (decl) == 0)
  837.     return;
  838.  
  839.   current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (decl));
  840.  
  841.   switch (TREE_CODE (decl))
  842.     {
  843.     case CONST_DECL:
  844.       /* Enum values are defined by defining the enum type.  */
  845.       break;
  846.  
  847.     case FUNCTION_DECL:
  848.       if (DECL_RTL (decl) == 0)
  849.     return;
  850.       if (TREE_EXTERNAL (decl))
  851.     break;
  852.       if (GET_CODE (DECL_RTL (decl)) != MEM
  853.       || GET_CODE (XEXP (DECL_RTL (decl), 0)) != SYMBOL_REF)
  854.     break;
  855.       FORCE_TEXT;
  856.       fprintf (asmfile, ".stabs \"%s:%c",
  857.            IDENTIFIER_POINTER (DECL_NAME (decl)),
  858.            TREE_PUBLIC (decl) ? 'F' : 'f');
  859.  
  860.       current_sym_code = N_FUN;
  861.       current_sym_addr = XEXP (DECL_RTL (decl), 0);
  862.  
  863.       if (TREE_TYPE (TREE_TYPE (decl)))
  864.     dbxout_type (TREE_TYPE (TREE_TYPE (decl)), 0);
  865.       else
  866.     dbxout_type (void_type_node, 0);
  867.       dbxout_finish_symbol ();
  868.       break;
  869.  
  870.     case TYPE_DECL:
  871. #if 0
  872.       /* This seems all wrong.  Outputting most kinds of types gives no name
  873.      at all.  A true definition gives no name; a cross-ref for a
  874.      structure can give the tag name, but not a type name.
  875.      It seems that no typedef name is defined by outputting a type.  */
  876.  
  877.       /* If this typedef name was defined by outputting the type,
  878.      don't duplicate it.  */
  879.       if (typevec[TYPE_SYMTAB_ADDRESS (type)] == TYPE_DEFINED
  880.       && TYPE_NAME (TREE_TYPE (decl)) == decl)
  881.     return;
  882. #endif
  883.       /* Don't output the same typedef twice.
  884.          And don't output what language-specific stuff doesn't want output.  */
  885.       if (TREE_ASM_WRITTEN (decl)
  886.       || lang_output_debug_info (TREE_TYPE (decl)) == 0)
  887.     return;
  888.  
  889.       /* Output typedef name.  */
  890.       FORCE_TEXT;
  891.       fprintf (asmfile, ".stabs \"%s:t",
  892.            IDENTIFIER_POINTER (DECL_NAME (decl)));
  893.  
  894.       current_sym_code = N_LSYM;
  895.  
  896.       dbxout_type (TREE_TYPE (decl), 1);
  897.       dbxout_finish_symbol ();
  898.  
  899.       /* Prevent duplicate output of a typedef.  */
  900.       TREE_ASM_WRITTEN (decl) = 1;
  901.       break;
  902.       
  903.     case PARM_DECL:
  904.       /* Parm decls go in their own separate chains
  905.      and are output by dbxout_reg_parms and dbxout_parms.  */
  906.       abort ();
  907.  
  908.     case RESULT_DECL:
  909.       /* Named return value, treat like a VAR_DECL.  */
  910.     case VAR_DECL:
  911.       if (DECL_RTL (decl) == 0)
  912.     return;
  913.       /* Don't mention a variable that is external.
  914.      Let the file that defines it describe it.  */
  915.       if (TREE_EXTERNAL (decl))
  916.     break;
  917.  
  918.       /* If the variable is really a constant, inform dbx of such.  */
  919.       if (TREE_STATIC (decl) && TREE_READONLY (decl)
  920.       && DECL_INITIAL (decl) != 0
  921.       && (DECL_FIELD_CONTEXT (decl) == NULL_TREE
  922.           || TREE_CODE (DECL_FIELD_CONTEXT (decl)) == LET_STMT))
  923.     {
  924.       if (TREE_PUBLIC (decl) == 0)
  925.         {
  926.           /* The sun4 assembler does not grok this.  */
  927.           name = IDENTIFIER_POINTER (DECL_NAME (decl));
  928.           if (TREE_CODE (TREE_TYPE (decl)) == INTEGER_TYPE
  929.           || TREE_CODE (TREE_TYPE (decl)) == ENUMERAL_TYPE)
  930.         {
  931.           int ival = TREE_INT_CST_LOW (DECL_INITIAL (decl));
  932.           fprintf (asmfile, ".stabs \"%s:c=i%d\",0x%x,0,0,0\n",
  933.                name, ival, N_LSYM);
  934.           return;
  935.         }
  936.           else if (TREE_CODE (TREE_TYPE (decl)) == REAL_TYPE)
  937.         {
  938.           /* don't know how to do this yet.  */
  939.         }
  940.           break;
  941.         }
  942.       /* else it is something we handle like a normal variable.  */
  943.     }
  944.  
  945.       /* Don't mention a variable at all
  946.      if it was completely optimized into nothingness.  */
  947.       if (GET_CODE (DECL_RTL (decl)) == REG
  948.       && (REGNO (DECL_RTL (decl)) < 0
  949.           || REGNO (DECL_RTL (decl)) >= FIRST_PSEUDO_REGISTER))
  950.     break;
  951.  
  952.       /* The kind-of-variable letter depends on where
  953.      the variable is and on the scope of its name:
  954.      G and N_GSYM for static storage and global scope,
  955.      S for static storage and file scope,
  956.      V for static storage and local scope,
  957.         for those two, use N_LCSYM if data is in bss segment,
  958.         N_STSYM if in data segment, N_FUN otherwise.
  959.         (We used N_FUN originally, then changed to N_STSYM
  960.         to please GDB.  However, it seems that confused ld.
  961.         Now GDB has been fixed to like N_FUN, says Kingdon.)
  962.      no letter at all, and N_LSYM, for auto variable,
  963.      r and N_RSYM for register variable.  */
  964.  
  965.       if (GET_CODE (DECL_RTL (decl)) == MEM
  966.       && GET_CODE (XEXP (DECL_RTL (decl), 0)) == SYMBOL_REF)
  967.     {
  968.       if (TREE_PUBLIC (decl))
  969.         {
  970.           letter = 'G';
  971.           current_sym_code = N_GSYM;
  972.         }
  973.       else
  974.         {
  975.           current_sym_addr = XEXP (DECL_RTL (decl), 0);
  976.  
  977.           letter = TREE_PERMANENT (decl) ? 'S' : 'V';
  978.  
  979.           if (!DECL_INITIAL (decl))
  980.         current_sym_code = N_LCSYM;
  981.           else if (TREE_READONLY (decl) && ! TREE_VOLATILE (decl))
  982.         /* This is not quite right, but it's the closest
  983.            of all the codes that Unix defines.  */
  984.         current_sym_code = N_FUN;
  985.           else
  986.         current_sym_code = N_STSYM;
  987.         }
  988.     }
  989.       else if (GET_CODE (DECL_RTL (decl)) == REG)
  990.     {
  991.       letter = 'r';
  992.       current_sym_code = N_RSYM;
  993.       current_sym_value = DBX_REGISTER_NUMBER (REGNO (DECL_RTL (decl)));
  994.     }
  995.       else if (GET_CODE (DECL_RTL (decl)) == MEM
  996.            && (GET_CODE (XEXP (DECL_RTL (decl), 0)) == MEM
  997.            || (GET_CODE (XEXP (DECL_RTL (decl), 0)) == REG
  998.                && REGNO (XEXP (DECL_RTL (decl), 0)) != FRAME_POINTER_REGNUM)))
  999.     /* If the value is indirect by memory or by a register
  1000.        that isn't the frame pointer
  1001.        then it means the object is variable-sized and address through
  1002.        that register or stack slot.  DBX has no way to represent this
  1003.        so all we can do is output the variable as a pointer.
  1004.        If it's not a parameter, ignore it.
  1005.        (VAR_DECLs like this can be made by integrate.c.)  */
  1006.     {
  1007.       if (GET_CODE (XEXP (DECL_RTL (decl), 0)) == REG)
  1008.         {
  1009.           letter = 'r';
  1010.           current_sym_code = N_RSYM;
  1011.           current_sym_value = DBX_REGISTER_NUMBER (REGNO (XEXP (DECL_RTL (decl), 0)));
  1012.         }
  1013.       else
  1014.         {
  1015.           current_sym_code = N_LSYM;
  1016.           /* DECL_RTL looks like (MEM (MEM (PLUS (REG...) (CONST_INT...)))).
  1017.          We want the value of that CONST_INT.  */
  1018.           current_sym_value = INTVAL (XEXP (XEXP (XEXP (DECL_RTL (decl), 0), 0), 1));
  1019.         }
  1020.  
  1021.       /* Effectively do build_pointer_type, but don't cache this type,
  1022.          since it might be temporary whereas the type it points to
  1023.          might have been saved for inlining.  */
  1024.       type = make_node (POINTER_TYPE);
  1025.       TREE_TYPE (type) = TREE_TYPE (decl);
  1026.     }
  1027.       else if (GET_CODE (DECL_RTL (decl)) == MEM
  1028.            && GET_CODE (XEXP (DECL_RTL (decl), 0)) == REG)
  1029.     {
  1030.       current_sym_code = N_LSYM;
  1031.       current_sym_value = 0;
  1032.     }
  1033.       else if (GET_CODE (DECL_RTL (decl)) == MEM
  1034.            && GET_CODE (XEXP (DECL_RTL (decl), 0)) == PLUS
  1035.            && GET_CODE (XEXP (XEXP (DECL_RTL (decl), 0), 1)) == CONST_INT)
  1036.     {
  1037.       current_sym_code = N_LSYM;
  1038.       /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...)))
  1039.          We want the value of that CONST_INT.  */
  1040.       current_sym_value = INTVAL (XEXP (XEXP (DECL_RTL (decl), 0), 1));
  1041.     }
  1042.       else
  1043.     /* Address might be a MEM, when DECL is a variable-sized object.
  1044.        Or it might be const0_rtx, meaning previous passes
  1045.        want us to ignore this variable.  */
  1046.     break;
  1047.  
  1048.       /* Ok, start a symtab entry and output the variable name.  */
  1049.       FORCE_TEXT;
  1050.       /* One slight hitch: if this is a VAR_DECL which is a static
  1051.      class member, we must put out the mangled name instead of the
  1052.      DECL_NAME.  */
  1053.       /* Note also that static member (variable) names DO NOT begin
  1054.      with underscores in .stabs directives.  */
  1055.       if (DECL_LANG_SPECIFIC (decl))
  1056.     {
  1057.       name = DECL_ASSEMBLER_NAME (decl);
  1058.  
  1059.       /* Adding 1 here only works on systems
  1060.          which flush an initial underscore.  */
  1061.       if (name[0] == '_')
  1062.         name += 1;
  1063.     }
  1064.       else name = IDENTIFIER_POINTER (DECL_NAME (decl));
  1065.  
  1066.       fprintf (asmfile, ".stabs \"%s:", name);
  1067.       if (letter) putc (letter, asmfile);
  1068.       dbxout_type (type, 0);
  1069.       dbxout_finish_symbol ();
  1070.       break;
  1071.     }
  1072. }
  1073.  
  1074. static void
  1075. dbxout_finish_symbol ()
  1076. {
  1077.   fprintf (asmfile, "\",%d,0,0,", current_sym_code);
  1078.   if (current_sym_addr)
  1079.     output_addr_const (asmfile, current_sym_addr);
  1080.   else
  1081.     fprintf (asmfile, "%d", current_sym_value);
  1082.   putc ('\n', asmfile);
  1083. }
  1084.  
  1085. /* Output definitions of all the decls in a chain.  */
  1086.  
  1087. static void
  1088. dbxout_syms (syms)
  1089.      tree syms;
  1090. {
  1091.   while (syms)
  1092.     {
  1093.       dbxout_symbol (syms, 1);
  1094.       syms = TREE_CHAIN (syms);
  1095.     }
  1096. }
  1097.  
  1098. /* The following two functions output definitions of function parameters.
  1099.    Each parameter gets a definition locating it in the parameter list.
  1100.    Each parameter that is a register variable gets a second definition
  1101.    locating it in the register.
  1102.  
  1103.    Printing or argument lists in gdb uses the definitions that
  1104.    locate in the parameter list.  But reference to the variable in
  1105.    expressions uses preferentially the definition as a register.  */
  1106.  
  1107. /* Output definitions, referring to storage in the parmlist,
  1108.    of all the parms in PARMS, which is a chain of PARM_DECL nodes.  */
  1109.  
  1110. static void
  1111. dbxout_parms (parms)
  1112.      tree parms;
  1113. {
  1114.   for (; parms; parms = TREE_CHAIN (parms))
  1115.     {
  1116.       if (DECL_OFFSET (parms) >= 0)
  1117.     {
  1118.       current_sym_code = N_PSYM;
  1119.       current_sym_value = DECL_OFFSET (parms) / BITS_PER_UNIT;
  1120.       current_sym_addr = 0;
  1121.  
  1122.       FORCE_TEXT;
  1123.       if (DECL_NAME (parms))
  1124.         {
  1125.           current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms));
  1126.  
  1127.           fprintf (asmfile, ".stabs \"%s:p",
  1128.                IDENTIFIER_POINTER (DECL_NAME (parms)));
  1129.         }
  1130.       else
  1131.         {
  1132.           current_sym_nchars = 8;
  1133.           fprintf (asmfile, ".stabs \"(anon):p");
  1134.         }
  1135.  
  1136.       if (GET_CODE (DECL_RTL (parms)) == REG
  1137.           && REGNO (DECL_RTL (parms)) >= 0
  1138.           && REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER)
  1139.         dbxout_type (DECL_ARG_TYPE (parms), 0);
  1140.       else
  1141.         {
  1142.           /* This is the case where the parm is passed as an int or double
  1143.          and it is converted to a char, short or float and stored back
  1144.          in the parmlist.  In this case, describe the parm
  1145.          with the variable's declared type, and adjust the address
  1146.          if the least significant bytes (which we are using) are not
  1147.          the first ones.  */
  1148. #ifdef BYTES_BIG_ENDIAN
  1149.           if (TREE_TYPE (parms) != DECL_ARG_TYPE (parms))
  1150.         current_sym_value += (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms)))
  1151.                       - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms))));
  1152. #endif
  1153.  
  1154.           if (GET_CODE (DECL_RTL (parms)) == MEM
  1155.           && GET_CODE (XEXP (DECL_RTL (parms), 0)) == PLUS
  1156.           && GET_CODE (XEXP (XEXP (DECL_RTL (parms), 0), 1)) == CONST_INT
  1157.           && INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1)) == current_sym_value)
  1158.         dbxout_type (TREE_TYPE (parms), 0);
  1159.           else
  1160.         {
  1161.           current_sym_value = DECL_OFFSET (parms) / BITS_PER_UNIT;
  1162.           dbxout_type (DECL_ARG_TYPE (parms), 0);
  1163.         }
  1164.         }
  1165.       dbxout_finish_symbol ();
  1166.     }
  1167.       /* Parm was passed in registers.
  1168.      If it lives in a hard register, output a "regparm" symbol
  1169.      for the register it lives in.  */
  1170.       else if (GET_CODE (DECL_RTL (parms)) == REG
  1171.            && REGNO (DECL_RTL (parms)) >= 0
  1172.            && REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER)
  1173.     {
  1174.       current_sym_code = N_RSYM;
  1175.       current_sym_value = DBX_REGISTER_NUMBER (REGNO (DECL_RTL (parms)));
  1176.       current_sym_addr = 0;
  1177.  
  1178.       FORCE_TEXT;
  1179.       if (DECL_NAME (parms))
  1180.         {
  1181.           current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms));
  1182.           fprintf (asmfile, ".stabs \"%s:P",
  1183.                IDENTIFIER_POINTER (DECL_NAME (parms)));
  1184.         }
  1185.       else
  1186.         {
  1187.           current_sym_nchars = 8;
  1188.           fprintf (asmfile, ".stabs \"(anon):P");
  1189.         }
  1190.  
  1191.       dbxout_type (DECL_ARG_TYPE (parms), 0);
  1192.       dbxout_finish_symbol ();
  1193.     }
  1194.       else if (GET_CODE (DECL_RTL (parms)) == MEM
  1195.            && XEXP (DECL_RTL (parms), 0) != const0_rtx)
  1196.     {
  1197.       current_sym_code = N_LSYM;
  1198.       /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))).
  1199.          We want the value of that CONST_INT.  */
  1200.       current_sym_value = INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1));
  1201.       current_sym_addr = 0;
  1202.  
  1203.       FORCE_TEXT;
  1204.       if (DECL_NAME (parms))
  1205.         {
  1206.           current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms));
  1207.           fprintf (asmfile, ".stabs \"%s:p",
  1208.                IDENTIFIER_POINTER (DECL_NAME (parms)));
  1209.         }
  1210.       else
  1211.         {
  1212.           current_sym_nchars = 8;
  1213.           fprintf (asmfile, ".stabs \"(anon):p");
  1214.         }
  1215.  
  1216. #if 0 /* This is actually the case in which a parameter
  1217.      is passed in registers but lives on the stack in a local slot.
  1218.      The address we are using is already correct, so don't change it.  */
  1219.  
  1220.       /* This is the case where the parm is passed as an int or double
  1221.          and it is converted to a char, short or float and stored back
  1222.          in the parmlist.  In this case, describe the parm
  1223.          with the variable's declared type, and adjust the address
  1224.          if the least significant bytes (which we are using) are not
  1225.          the first ones.  */
  1226. #ifdef BYTES_BIG_ENDIAN
  1227.       if (TREE_TYPE (parms) != DECL_ARG_TYPE (parms))
  1228.         current_sym_value += (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms)))
  1229.                   - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms))));
  1230. #endif
  1231. #endif /* 0 */
  1232.  
  1233.       dbxout_type (TREE_TYPE (parms), 0);
  1234.       dbxout_finish_symbol ();
  1235.     }
  1236.     }
  1237. }
  1238.  
  1239. /* Output definitions, referring to registers,
  1240.    of all the parms in PARMS which are stored in registers during the function.
  1241.    PARMS is a chain of PARM_DECL nodes.  */
  1242.  
  1243. static void
  1244. dbxout_reg_parms (parms)
  1245.      tree parms;
  1246. {
  1247.   while (parms)
  1248.     {
  1249.       /* Report parms that live in registers during the function.  */
  1250.       if (GET_CODE (DECL_RTL (parms)) == REG
  1251.       && REGNO (DECL_RTL (parms)) >= 0
  1252.       && REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER
  1253.       && DECL_OFFSET (parms) >= 0)
  1254.     {
  1255.       current_sym_code = N_RSYM;
  1256.       current_sym_value = DBX_REGISTER_NUMBER (REGNO (DECL_RTL (parms)));
  1257.       current_sym_addr = 0;
  1258.  
  1259.       FORCE_TEXT;
  1260.       if (DECL_NAME (parms))
  1261.         {
  1262.           current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms));
  1263.           fprintf (asmfile, ".stabs \"%s:r",
  1264.                IDENTIFIER_POINTER (DECL_NAME (parms)));
  1265.         }
  1266.       else
  1267.         {
  1268.           current_sym_nchars = 8;
  1269.           fprintf (asmfile, ".stabs \"(anon):r");
  1270.         }
  1271.       dbxout_type (TREE_TYPE (parms), 0);
  1272.       dbxout_finish_symbol ();
  1273.     }
  1274.       /* Report parms that live in memory but outside the parmlist.  */
  1275.       else if (GET_CODE (DECL_RTL (parms)) == MEM
  1276.            && GET_CODE (XEXP (DECL_RTL (parms), 0)) == PLUS
  1277.            && GET_CODE (XEXP (XEXP (DECL_RTL (parms), 0), 1)) == CONST_INT)
  1278.     {
  1279.       int offset = DECL_OFFSET (parms) / BITS_PER_UNIT;
  1280.       /* A parm declared char is really passed as an int,
  1281.          so it occupies the least significant bytes.
  1282.          On a big-endian machine those are not the low-numbered ones.  */
  1283. #ifdef BYTES_BIG_ENDIAN
  1284.       if (offset != -1 && TREE_TYPE (parms) != DECL_ARG_TYPE (parms))
  1285.         offset += (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms)))
  1286.                - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms))));
  1287. #endif
  1288.       if (INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1)) != offset)
  1289.         {
  1290.           current_sym_code = N_LSYM;
  1291.           current_sym_value = INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1));
  1292.           current_sym_addr = 0;
  1293.           FORCE_TEXT;
  1294.           if (DECL_NAME (parms))
  1295.         {
  1296.           current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms));
  1297.           fprintf (asmfile, ".stabs \"%s:",
  1298.                IDENTIFIER_POINTER (DECL_NAME (parms)));
  1299.         }
  1300.           else
  1301.         {
  1302.           current_sym_nchars = 8;
  1303.           fprintf (asmfile, ".stabs \"(anon):");
  1304.         }
  1305.           dbxout_type (TREE_TYPE (parms), 0);
  1306.           dbxout_finish_symbol ();
  1307.         }
  1308.     }
  1309.       parms = TREE_CHAIN (parms);
  1310.     }
  1311. }
  1312.  
  1313. /* Given a chain of ..._TYPE nodes (as come in a parameter list),
  1314.    output definitions of those names, in raw form */
  1315.  
  1316. void
  1317. dbxout_args (args)
  1318.      tree args;
  1319. {
  1320.   while (args)
  1321.     {
  1322.       putc (',', asmfile);
  1323.       dbxout_type (TREE_VALUE (args), 0);
  1324.       CHARS (1);
  1325.       args = TREE_CHAIN (args);
  1326.     }
  1327. }
  1328.  
  1329. /* Given a chain of ..._TYPE nodes,
  1330.    find those which have typedef names and output those names.
  1331.    This is to ensure those types get output.  */
  1332.  
  1333. void
  1334. dbxout_types (types)
  1335.      register tree types;
  1336. {
  1337.   while (types)
  1338.     {
  1339.       if (TYPE_NAME (types)
  1340.       && TREE_CODE (TYPE_NAME (types)) == TYPE_DECL
  1341.       && ! TREE_ASM_WRITTEN (TYPE_NAME (types)))
  1342.     dbxout_symbol (TYPE_NAME (types), 1);
  1343.       types = TREE_CHAIN (types);
  1344.     }
  1345. }
  1346.  
  1347. /* Output the tags (struct, union and enum definitions with names) for a block,
  1348.    given a list of them (a chain of TREE_LIST nodes) in TAGS.
  1349.    We must check to include those that have been mentioned already with
  1350.    only a cross-reference.  */
  1351.  
  1352. void
  1353. dbxout_tags (tags)
  1354.      tree tags;
  1355. {
  1356.   register tree link;
  1357.   for (link = tags; link; link = TREE_CHAIN (link))
  1358.     {
  1359.       register tree type = TYPE_MAIN_VARIANT (TREE_VALUE (link));
  1360.       if (TREE_PURPOSE (link) != 0
  1361.       && ! TREE_ASM_WRITTEN (link)
  1362.       && TYPE_SIZE (type) != 0
  1363.       && lang_output_debug_info (type))
  1364.     {
  1365.       TREE_ASM_WRITTEN (link) = 1;
  1366.       current_sym_code = N_LSYM;
  1367.       current_sym_value = 0;
  1368.       current_sym_addr = 0;
  1369.       current_sym_nchars = 2 + IDENTIFIER_LENGTH (TREE_PURPOSE (link));
  1370.  
  1371.       FORCE_TEXT;
  1372.       fprintf (asmfile, ".stabs \"%s:T",
  1373.            ANON_AGGRNAME_P (TREE_PURPOSE (link)) ? "" : IDENTIFIER_POINTER (TREE_PURPOSE (link)));
  1374.       dbxout_type (type, 1);
  1375.       dbxout_finish_symbol ();
  1376.  
  1377. /* Change by Bryan Boreham, Kewill, Fri Sep 22 16:57:42 1989.
  1378.    Added to make sure all fully-output structs have typedefs.    */
  1379.  
  1380.       if (!ANON_AGGRNAME_P (TREE_PURPOSE (link)))
  1381.         {
  1382.           fprintf (asmfile, ".stabs \"%s:t",
  1383.                IDENTIFIER_POINTER (TREE_PURPOSE (link)));
  1384.           
  1385.           current_sym_code = N_LSYM;
  1386.  
  1387.           dbxout_type (type, 1);
  1388.           dbxout_finish_symbol ();
  1389.         }
  1390.     }
  1391.     }
  1392. }
  1393.  
  1394. /* Output everything about a symbol block (that is to say, a LET_STMT node
  1395.    that represents a scope level),
  1396.    including recursive output of contained blocks.
  1397.  
  1398.    STMT is the LET_STMT node.
  1399.    DEPTH is its depth within containing symbol blocks.
  1400.    ARGS is usually zero; but for the outermost block of the
  1401.    body of a function, it is a chain of PARM_DECLs for the function parameters.
  1402.    We output definitions of all the register parms
  1403.    as if they were local variables of that block.
  1404.  
  1405.    Actually, STMT may be several statements chained together.
  1406.    We handle them all in sequence.  */
  1407.  
  1408. static void
  1409. dbxout_block (stmt, depth, args)
  1410.      register tree stmt;
  1411.      int depth;
  1412.      tree args;
  1413. {
  1414.   int blocknum;
  1415.  
  1416.   while (stmt)
  1417.     {
  1418.       switch (TREE_CODE (stmt))
  1419.     {
  1420.     case COMPOUND_STMT:
  1421.     case LOOP_STMT:
  1422.       dbxout_block (STMT_BODY (stmt), depth, 0);
  1423.       break;
  1424.  
  1425.     case IF_STMT:
  1426.       dbxout_block (STMT_THEN (stmt), depth, 0);
  1427.       dbxout_block (STMT_ELSE (stmt), depth, 0);
  1428.       break;
  1429.  
  1430.     case LET_STMT:
  1431.       /* Ignore LET_STMTs for blocks never really used to make RTL.  */
  1432.       if (! TREE_USED (stmt))
  1433.         break;
  1434.       /* In dbx format, the syms of a block come before the N_LBRAC.  */
  1435.       dbxout_tags (STMT_TYPE_TAGS (stmt));
  1436.       dbxout_syms (STMT_VARS (stmt));
  1437.       if (args)
  1438.         dbxout_reg_parms (args);
  1439.  
  1440.       /* Now output an N_LBRAC symbol to represent the beginning of
  1441.          the block.  Use the block's tree-walk order to generate
  1442.          the assembler symbols LBBn and LBEn
  1443.          that final will define around the code in this block.  */
  1444.       if (depth > 0)
  1445.         {
  1446.           char buf[20];
  1447.           blocknum = next_block_number++;
  1448.           ASM_GENERATE_INTERNAL_LABEL (buf, "LBB", blocknum);
  1449.           fprintf (asmfile, ".stabn %d,0,0,", N_LBRAC);
  1450.           assemble_name (asmfile, buf);
  1451.           fprintf (asmfile, "\n");
  1452.         }
  1453.  
  1454.       /* Output the subblocks.  */
  1455.       dbxout_block (STMT_SUBBLOCKS (stmt), depth + 1, 0);
  1456.  
  1457.       /* Refer to the marker for the end of the block.  */
  1458.       if (depth > 0)
  1459.         {
  1460.           char buf[20];
  1461.           ASM_GENERATE_INTERNAL_LABEL (buf, "LBE", blocknum);
  1462.           fprintf (asmfile, ".stabn %d,0,0,", N_RBRAC);
  1463.           assemble_name (asmfile, buf);
  1464.           fprintf (asmfile, "\n");
  1465.         }
  1466.     }
  1467.       stmt = TREE_CHAIN (stmt);
  1468.     }
  1469. }
  1470.  
  1471. /* Output dbx data for a function definition.
  1472.    This includes a definition of the function name itself (a symbol),
  1473.    definitions of the parameters (locating them in the parameter list)
  1474.    and then output the block that makes up the function's body
  1475.    (including all the auto variables of the function).  */
  1476.  
  1477. void
  1478. dbxout_function (decl)
  1479.      tree decl;
  1480. {
  1481.   extern tree value_identifier;
  1482.  
  1483.   dbxout_symbol (decl, 0);
  1484.   dbxout_parms (DECL_ARGUMENTS (decl));
  1485.   if (DECL_NAME (DECL_RESULT (decl)) != value_identifier)
  1486.     dbxout_symbol (DECL_RESULT (decl), 1);
  1487.   dbxout_block (DECL_INITIAL (decl), 0, DECL_ARGUMENTS (decl));
  1488.   
  1489.   /* If we made any temporary types in this fn that weren't
  1490.      output, output them now.  */
  1491.   dbxout_types (get_temporary_types ());
  1492. }
  1493.  
  1494. /* GNU C++ extensions.  */
  1495.  
  1496. /* At the start of the file, emit symbolic information to orient
  1497.    GDB for this particular file's exception handling implementation.
  1498.    EH_TYPE is the type name of the exception type.
  1499.    EH_DECL is the global root of the exception handler stack.  */
  1500.  
  1501. void
  1502. dbxout_eh_init (eh_type, eh_decl)
  1503.      tree eh_type, eh_decl;
  1504. {
  1505. }
  1506.  
  1507. #else /* not DBX_DEBUGGING_INFO */
  1508.  
  1509. void
  1510. dbxout_init (asm_file, input_file_name)
  1511.      FILE *asm_file;
  1512.      char *input_file_name;
  1513. {}
  1514.  
  1515. void
  1516. dbxout_symbol (decl, local)
  1517.      tree decl;
  1518.      int local;
  1519. {}
  1520.  
  1521. void
  1522. dbxout_types (types)
  1523.      register tree types;
  1524. {}
  1525.  
  1526. void
  1527. dbxout_tags (tags)
  1528.      tree tags;
  1529. {}
  1530.  
  1531. void
  1532. dbxout_function (decl)
  1533.      tree decl;
  1534. {}
  1535.  
  1536. #endif /* DBX_DEBUGGING_INFO */
  1537.